//
//  BuyClassListViewController.m
//  WZCLApp
//
//  Created by chirui on 2018/7/13.
//  Copyright © 2018年 Shui. All rights reserved.
//

#import "BuyClassListViewController.h"
#import "BuyClssListTableViewCell.h"

@interface BuyClassListViewController ()<UITableViewDelegate,UITableViewDataSource>{
    
    UITableView * _tableView;
}
@end

@implementation BuyClassListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    TitleView(@"购课单");
    [self creatTableView];
    
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithIcon:@"icon_return_back" target:self action:@selector(backBtnClick)];
    [self creatDownView];
}

-(void)backBtnClick{
    
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)creatDownView{
    
    UIView * bgview =[[UIView alloc]initWithFrame:CGRectMake(0,HEIGHT-49-SH_TopHeight, WIDTH, 49)];
    bgview.backgroundColor =[UIColor whiteColor];
    bgview.layer.borderWidth = 0.5f;
    bgview.layer.borderColor = [UIColor groupTableViewBackgroundColor].CGColor;
    
    UIButton * allchooseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    allchooseBtn.frame = CGRectMake(10, 4, 60, 40);
    [allchooseBtn setImage:ImageName(@"icon_address_choice_pre") forState:UIControlStateNormal];
    [allchooseBtn setImage:ImageName(@"icon_address_choice") forState:UIControlStateSelected];
    [allchooseBtn setTitle:@"全选" forState:UIControlStateNormal];
    [allchooseBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [allchooseBtn addTarget:self action:@selector(allChooseBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    allchooseBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    [bgview addSubview:allchooseBtn];
    
    UILabel * moneyLabel  =[[UILabel alloc]initWithFrame:CGRectMake(70, 0, WIDTH -70-100, 49)];
    moneyLabel.font = [UIFont systemFontOfSize:15];
    moneyLabel.textColor = [UIColor blackColor];
    moneyLabel.attributedText = [SHJudgeTools changeAllStr:@"总计：￥899.00" partStr:@"￥899.00" color:[UIColor orangeColor] font:17];
    moneyLabel.textAlignment = NSTextAlignmentCenter;
    [bgview addSubview:moneyLabel];
    
    
    UIButton * payBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    payBtn.frame = CGRectMake(WIDTH -100, 5, 100, 39);
    payBtn.backgroundColor = [UIColor orangeColor];
    payBtn.layer.cornerRadius = 22.5f;
    payBtn.layer.masksToBounds = YES;
    [payBtn setTitle:@"立即付款" forState:UIControlStateNormal];
    [payBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    payBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    [bgview addSubview:payBtn];
    
    
    [self.view addSubview:bgview];
}

-(void)allChooseBtnClick:(UIButton *)btn{
    
    btn.selected = !btn.selected;
}

-(void)creatTableView {
    
    _tableView  =[[UITableView alloc]initWithFrame:CGRectMake(0,0, WIDTH, HEIGHT-SH_TopHeight-49)
                                             style:UITableViewStyleGrouped];
    _tableView.dataSource=self;
    _tableView.delegate =self;
    UIView * view =[[UIView alloc]init];
    _tableView.tableFooterView =view;
    [_tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    [_tableView registerNib:[UINib nibWithNibName:@"BuyClssListTableViewCell" bundle:nil] forCellReuseIdentifier:[BuyClssListTableViewCell reuseIdentifier]];
    
    [self.view addSubview:_tableView];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 5;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPat{
    
    return 190;
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return  0.01;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    
    return 0.01;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    //    NSDictionary * dic = _dataArray[indexPath.row];
    BuyClssListTableViewCell  * cell = [tableView dequeueReusableCellWithIdentifier:[BuyClssListTableViewCell  reuseIdentifier]];
    
    //
    //    [cell.heardImage sd_setImageWithURL:[NSURL URLWithString:dic[@"cover"]] placeholderImage:[UIImage imageNamed:@"img_1"]];
    //    cell.titleLabel.frame = CGRectMake(109, 10, WIDTH - 120, 20);
    //    //    NSString * titleStr = dic[@"title"];
    //    //    cell.titleLabel.text = titleStr;
    //    //
    //    cell.titleLabel.numberOfLines = 2;
    //    [cell.titleLabel sizeToFit];
    //    //
    //    cell.detailsLabel.frame = CGRectMake(109, CGRectGetMaxY(cell.titleLabel.frame)+4, WIDTH - 140, 20);
    //
    //    cell.detailsLabel.text = dic[@"discribe"];
    //    cell.timeLabel.text = dic[@"create_time"];
    return cell;
    
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    
    return nil;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
    return nil;
}


@end
